import dt from '@dt/dt'
import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'

class SearchOpt extends Opt {
  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      this.organization(),
      houseOpt.create({
        to: (info) => {
          return {
            housesId: info.housesId
          }
        }
      }),
      {
        title: '申请月份',
        placeholder: '全部',
        key: 'applyMonth',
        date: {
          type: 'month'
        }
      }
    ]
  }

  organization() {
    let orgs = []
    let opt = {
      key: 'orgIds',
      title: '所属组织',
      tree: {
        options: orgs
      }
    }
    toolMgr.organization(2).then((res) => {
      orgs = res
      opt.tree.options = orgs
    })
    return opt
  }
}

export default SearchOpt
